package com.songcha.module_bookdetail.ui.adapter

import android.content.Context
import android.graphics.Color
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.songcha.library_business.util.MajiaBaoUtil
import com.songcha.library_common.ui.view.CustomButton
import com.songcha.library_common.util.ColorUtil
import com.songcha.module_bookdetail.R

class DialogReportTypeAdapter(val mContext: Context, list:MutableList<String>):BaseQuickAdapter<String,BaseViewHolder>(R.layout.bookdetail_item_report_type,list) {
    //class CommentReportItemType(val title:String)

    var mSelectIndex=-1

    override fun convert(holder: BaseViewHolder, item: String) {
        val btn=holder.getView<CustomButton>(R.id.bookdetail_btn_report_type)
        btn.text=item
        if(mSelectIndex==holder.bindingAdapterPosition){
            val majiaName = MajiaBaoUtil.getMajiaName()
            if(majiaName == "douyue"){
                btn.setStartColor(Color.parseColor("#C987FF"))
                btn.setEndColor(Color.parseColor("#7B7EFF"))
            }else if(majiaName == "beike"){
                btn.setStartColor(Color.parseColor("#FFA9D1"))
                btn.setEndColor(Color.parseColor("#FF7BA3"))
            }
            //btn.setBtnBackgroundColor(ColorUtil.getResourceColor(mContext, com.songcha.library_common.R.color.primary))
        }else{
            btn.setBtnBackgroundColor(Color.parseColor("#CDD1D3"))
            //btn.setBtnBackgroundColor(ColorUtil.getResourceColor(mContext, com.songcha.library_common.R.color.gray_cc))
        }
        btn.setOnClickListener {
            mSelectIndex=holder.bindingAdapterPosition
            notifyDataSetChanged()
        }
    }


    fun getSelectIndex():Int{
        return mSelectIndex
    }
}